package org.goobs.chess;

public class ChessMove {

	public char x0, x1;
	public int y0, y1;
	
	public ChessMove(char x0, int y0, char x1, int y1){
		this.x0 = x0;
		this.x1 = x1;
		this.y0 = y0;
		this.y1 = y1;
	}
	
	public String encode(){
		return x0 + "" + y0 + "-" + x1 + "" + y1;
	}
	
	public static ChessMove decode(String move){
		char x0 = move.charAt(0);
		int y0 = move.charAt(1) - '0';
		char x1 = move.charAt(3);
		int y1 = move.charAt(4) - '0';
		return new ChessMove(x0, y0, x1, y1);
	}
	
	public String toString(){
		return encode();
	}
}
